/**
 * Copyright (C), 2015-2021, XXX有限公司
 * FileName: FilesVisitController
 * Author:   wh
 * Date:     2021/12/2 22:47
 * Description: 档案借阅
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
package org.jeecg.modules.dzda.controller;

import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.modules.dzda.entity.FileVisit;
import org.jeecg.modules.dzda.service.FilesVisitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 功能描述:
 * <档案借阅>
 *
 * @program: wh-boot
 * @ClassName: FilesVisitController
 * @author: wanghui
 * @date: 2021/12/2 22:47
 * @Version: 1.0.0
 * @Copyright: 2021 Inc. All rights reserved. 注意: 本内容仅限于内部传阅,禁止外泄以及用于其他的商业目
 */
@Slf4j
@Api(tags="档案借阅")
@RestController
@RequestMapping("/dzda/visit")
public class FilesVisitController extends JeecgController<FileVisit, FilesVisitService> {

    @Autowired
    private FilesVisitService filesVisitService;

    @PostMapping(value = "/add")
    public Result<?> addVisit(@RequestBody FileVisit fileVisit){
        filesVisitService.addVisit(fileVisit);
        return Result.OK("申请成功");
    }

    @PostMapping(value = "/check")
    public Result<?> check(@RequestBody FileVisit fileVisit){
        FileVisit fileVisit1 = filesVisitService.getVisit(fileVisit);
        if(fileVisit1 != null){
            return Result.error("已经借阅过该档案，目前借阅还未过期，请勿重复申请！");
        }else {
            return Result.OK("申请成功");
        }
    }
}
